<template>
  <div class="container">
    <el-form ref="search" :inline="true" :model="formInline" class="search" label-width="100px" size="small">
      <el-form-item label="类别编号:">
        <el-input v-model="formInline.user" placeholder="请输入名称" />
      </el-form-item>
      <el-form-item label="类别名称:">
        <el-input v-model="formInline.user" placeholder="请输入名称" />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" size="mini" @click="onSubmit">查询</el-button>
        <el-button type="info" size="mini" @click="onSubmit">重置</el-button>
      </el-form-item>
    </el-form>
    <!-- 表格 -->
    <div class="table-wrap">
      <div class="f-betweenX table-header">
        <div class="table-title">
          <svg-icon icon-class="table_menu" class-name="icon-table" />
          查询结果 共找到 <span class="count">1006</span> 条符合的记录{{ maxTableHeight }}
        </div>
        <div class="table-control">
          <el-button type="primary" size="mini" icon="el-icon-plus" plain @click="handleAdd">
            新增
          </el-button>
        </div>
      </div>
      <el-table :data="tableData" style="width: 100%;margin-bottom: 20px;" row-key="id" border default-expand-all :tree-props="{children: 'children', hasChildren: 'hasChildren'}">
        <el-table-column fixed type="index" label="序号" width="50">
        </el-table-column>
        <el-table-column prop="date" label="类别编码">
        </el-table-column>
        <el-table-column prop="name" label="类别名称">
        </el-table-column>
        <el-table-column label="操作" align="center" fixed="right" width="200px">
          <template slot-scope="scope">
            <el-button size="mini" type="warning" icon="el-icon-check" plain @click="handleEdit(scope.$index, scope.row)">修改</el-button>
            <el-button size="mini" type="danger" icon="el-icon-delete" plain>删除</el-button>
          </template>
        </el-table-column>
      </el-table>
    </div>
    <!-- 分页 -->
    <!-- <pagination></pagination> -->
    <!-- 新增 -->
    <add ref="add" />
    <!-- 修改 -->
    <Edit ref="edit" />
  </div>
</template>

<script>
// import Tables from './Tables.vue'
// import Pagination from './Pagination.vue'
import tableHeight from '@/mixins/tableHeight'
import Add from './Add'
import Edit from './Edit.vue'
// import TreeSelect from '@/components/TreeSelect'

export default {
  components: {
    // Tables,
    // Pagination,
    Add,
    Edit

    // TreeSelect
  },
  mixins: [tableHeight],
  data () {
    return {
      formInline: {
        user: '',
        region: '',
        deptId: []
      },
      // officeTreeList: this.$config.treeList,//树形结构数据
      officeTreeList: [{
        label: '类别编码',
        children: [{
          label: '董事长',
          children: [{
            label: '三级 1-1-1'
          }]
        }]
      }, {
        label: '类别名称',
        children: [{
          label: '三级 1-1-1'
        }]
      }], // 树形结构数据
      tableData: [{
        id: 1,
        date: '2016-05-02',
        name: '王小虎',
        address: '上海市普陀区金沙江路 1518 弄'
      }, {
        id: 2,
        date: '2016-05-04',
        name: '王小虎',
        address: '上海市普陀区金沙江路 1517 弄'
      }, {
        id: 3,
        date: '2016-05-01',
        name: '王小虎',
        address: '上海市普陀区金沙江路 1519 弄',
        children: [{
          id: 31,
          date: '2016-05-01',
          name: '王小虎',
          address: '上海市普陀区金沙江路 1519 弄'
        }, {
          id: 32,
          date: '2016-05-01',
          name: '王小虎',
          address: '上海市普陀区金沙江路 1519 弄'
        }, {
          id: 32,
          date: '2016-05-01',
          name: '王小虎',
          address: '上海市普陀区金沙江路 1519 弄'
        }]
      }, {
        id: 4,
        date: '2016-05-03',
        name: '王小虎',
        address: '上海市普陀区金沙江路 1516 弄',
        children: [{
          id: 31,
          date: '2016-05-01',
          name: '王小虎',
          address: '上海市普陀区金沙江路 1519 弄'
        }, {
          id: 32,
          date: '2016-05-01',
          name: '王小虎',
          address: '上海市普陀区金沙江路 1519 弄'
        }, {
          id: 32,
          date: '2016-05-01',
          name: '王小虎',
          address: '上海市普陀区金沙江路 1519 弄'
        }]
      }],

    }
  },
  methods: {
    onSubmit () {
      console.log('submit!')
    },
    // 新增
    handleAdd () {
      this.$refs.add.toggleAdd(true)
    },
    handleEdit () {
      this.$refs.edit.togglePopup(true)
    }
    // 获取部门名称
    // popoverHide (checkedIds, checkedData, el) {
    //   if (el) {
    //     eval(' ( this.' + el + ' = checkedIds) ')
    //     console.log(1, this.formInline.deptId)
    //   }
    // }

  }
}
</script>

<style lang="scss" scoped>
.container {
  padding: 0 17px;
  .search {
    padding-top: 16px;
  }
  .table-wrap {
    .icon-table {
      margin: 0 10px;
    }
    .table-header {
      height: 52px;
      background: #f6f7f9;
      border: 1px solid #e1e7e9;
      border-bottom: none;
      font-size: 16px;
      color: #494949;
      line-height: 52px;
      border-radius: 4px 4px 0 0;
      .count {
        color: rgb(235, 104, 84);
      }
      .table-control {
        margin-right: 10px;
      }
    }
  }
  .pagination-wrap {
    height: 80px;
    .pagination {
      display: inline-block;
    }
  }
  .custom-tree-node {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 14px;
    padding-right: 8px;
  }
  .treeBox {
    width: 500px;
    height: 800px;
  }
}
</style>

<style lang="scss">
.tree-line {
  .el-tree-node {
    position: relative;
    padding-left: 16px; // 缩进量
  }
  .el-tree-node__children {
    padding-left: 16px; // 缩进量
  }

  // 竖线
  .el-tree-node::before {
    content: '';
    height: 100%;
    width: 1px;
    position: absolute;
    left: -3px;
    top: -26px;
    border-width: 1px;
    border-left: 1px dashed #52627c;
  }
  // 当前层最后一个节点的竖线高度固定
  .el-tree-node:last-child::before {
    height: 38px; // 可以自己调节到合适数值
  }

  // 横线
  .el-tree-node::after {
    content: '';
    width: 24px;
    height: 20px;
    position: absolute;
    left: -3px;
    top: 12px;
    border-width: 1px;
    border-top: 1px dashed #52627c;
  }

  // 去掉最顶层的虚线，放最下面样式才不会被上面的覆盖了
  & > .el-tree-node::after {
    border-top: none;
  }
  & > .el-tree-node::before {
    border-left: none;
  }

  // 展开关闭的icon
  .el-tree-node__expand-icon {
    font-size: 16px;
    // 叶子节点（无子节点）
    &.is-leaf {
      color: transparent;
      // display: none; // 也可以去掉
    }
  }
}
</style>
